import Vue from 'vue'
import singleSpaVue from 'single-spa-vue';

import App from './App.vue'
import router from './router'

Vue.config.productionTip = false

const appOptions = {
  el: '#vue', //挂载到父应用中的id为vue的标签
  router,
  render: h => h(App)
}

const vueLifeCycle = singleSpaVue({
  Vue,
  appOptions
});
console.log('vueLifeCycle:',vueLifeCycle); //里面包含微前端应用的三个方法 bootstrap、mount、unmount
/*
vueLifeCycle: { bootstrap: ƒ (), mount: ƒ (), unmount: ƒ (), update: ƒ ()}
*/

//如果是父应用引用我
if(window.singleSpaNavigate){
  //设置webpack打包时的资源公共路径
  __webpack_public_path__ = 'http://localhost:10000/'
}

//↓用于子应用单独开发时
if(!window.singleSpaNavigate){
  delete appOptions.el;
  new Vue(appOptions)
    .$mount('#app')
}

// 接入协议 (父应用会调用这些方法)
export const bootstrap = vueLifeCycle.bootstrap;
export const mount = vueLifeCycle.mount;
export const unmount = vueLifeCycle.unmount;

//将子应用打包成一个lib给父应用使用
